<?php
require('../../../public/connection.php');
require('../../../class/Mysql.php');
$data = (array)json_decode(file_get_contents("php://input", true));
$data["mode"] = (int)$data["mode"];
if (empty($data["id"]) || $data["mode"] > 2 || empty($data["date"]) || empty($data["name"])) {
    die(json_encode(array("code" => 400, "msg" => "格式错误", "data" => null)));
}
$edit_one_data = new Mysql();
$result = $edit_one_data->addOrEditData(
    "update accountings set name='{$data["name"]}',remarks='{$data["remarks"]}',money={$data["money"]},mode={$data["mode"]},date='{$data["date"]}' where id={$data["id"]};"
);
die(json_encode($result));
